package com.hd.abc.controller;

import com.github.pagehelper.PageInfo;
import com.hd.abc.sersions.ser;
import com.hd.abc.user.user;
import com.hd.abc.user.username;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/user")
public class ffff {
    @Autowired
    private ser s;

    @RequestMapping("/tz")
    public String sa(Model model, @RequestParam(defaultValue = "1")Integer pageIndex){
        if (pageIndex>2||pageIndex<1) {
            pageIndex=1;
        }
        PageInfo<user> querylimitdata = s.querylimitdata (pageIndex);
        List<username> queryusername = s.queryusername ();
        model.addAttribute ("mse",queryusername);
        model.addAttribute ("msg",querylimitdata);
        return "index";
    }
    @RequestMapping("/del")
    public String deldata(Integer id){
        int deldataa = s.deldataa (id);
        return "forward:/user/tz";
    }
    @RequestMapping("/upada")
    public String upadate(Model model, int id){
        user queryonedata = s.queryonedata (id);
        model.addAttribute ("msa", queryonedata);
        return "login";
    }
    @RequestMapping("/updataa")
    public String upadataa(user user){
        int updatedata = s.updatedata (user);
        return "forward:/user/tz";
    }
    @RequestMapping("/cale")
    public String categoryidquery(Model model,int categoryid){
        PageInfo<user> querynamealla = s.querynamealla (categoryid);
        model.addAttribute ("msg",querynamealla);
        return "index";
    }
    @RequestMapping("/add")
    public String addall(){
        return "addadd";
    }
    @RequestMapping("/adddata")
    public String adddata(user user){
        int adddataall = s.adddataall (user);
        return "forward:/user/tz";
    }
    @RequestMapping("/tzl")
    public String tz(){
        return "forward:/user/tz";
    }
}
